package guiservice.simulator;

import guiservice.server.logic.ServerImpl;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;

import javax.swing.*;
import java.awt.*;

/**
 * The application's main frame.
 */
public class GuiSimulatorView extends FrameView {

    private ServerImpl guiServer;

    public GuiSimulatorView(SingleFrameApplication app) {
        super(app);

        initComponents();
        this.getFrame().addKeyListener(DrawablePanel.GetKeyListener());

        guiServer = new ServerImpl();
        guiServer.start();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        mainPanel = new DrawablePanel();

        menuBar.setName("menuBar"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(GuiSimulatorApp.class).getContext().getResourceMap(GuiSimulatorView.class);
        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(GuiSimulatorApp.class).getContext().getActionMap(GuiSimulatorView.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        mainPanel.setBackground(Color.white); // NOI18N
        mainPanel.setFocusCycleRoot(true);
        mainPanel.setFocusTraversalPolicyProvider(true);
        mainPanel.setName("mainPanel"); // NOI18N
        this.getFrame().getContentPane().add(mainPanel);

        setMenuBar(menuBar);
    }// </editor-fold>

    // Variables declaration - do not modify
    private javax.swing.JMenuBar menuBar;
    private DrawablePanel mainPanel;
    // End of variables declaration

}
